<? include("inc.init.php");

switch($_POST["action"])
{
    case "newsletter":
        if(isRFC3696ValidEmailAddress($_POST['email']))
        {
            $newObj = new newsletter();
            $newObj->setDBLink($dbLink);
            $newObj->email = $_POST['email'];
            $newObj->userID_modified=0;
            if($newObj->save())
            {
                $response['success'] = true;
            }
            else $response['success'] = false;
            
            echo json_encode($response);
            exit();
        }
    break;
    case "donaciones":
        if(isRFC3696ValidEmailAddress($_POST['email']))
        {
            $obj = new donaciones();
            $obj->setDBLink($dbLink);
            $obj->email = $_POST['email'];
            $obj->nombre_apellido = $_POST['nombre'];
            $obj->telefono = $_POST['telefono'];
            $obj->mensaje = $_POST['mensaje'];
            $obj->userID_modified=0;
            if($obj->save())
            {
                $response['success'] = true;
            }
            else $response['success'] = false;
            
            echo json_encode($response);
            exit();
        }
    break;
    case "consulta":
        if(isRFC3696ValidEmailAddress($_POST['email']))
        {
            $obj = new consultas();
            $obj->setDBLink($dbLink);
            $obj->email = $_POST['email'];
            $obj->nombre_apellido = $_POST['nombre'];
            $obj->telefono = $_POST['telefono'];
            $obj->direccion = $_POST['direccion'];
            $obj->motivo= $_POST['tipo_mensaje'];
            $obj->mensaje = $_POST['mensaje'];
            $obj->userID_modified=0;
            if($obj->save())
            {
                $response['success'] = true;
            }
            else $response['success'] = false;
            
            echo json_encode($response);
            exit();
        }
    break;
}
?>
